import Vue from "vue";
import Vuex from "vuex";

//挂载Vuex
Vue.use(Vuex);

var state = {
  role: "",
  user_id: "",
  userinfo: "",
  name: "",
  login_status: false,
  click_order_status: true,
};

var mutations = {
  setName: (state, name) => {
    state.name = name;
  },
  setUserinfo: (state, userinfo) => {
    state.userinfo = userinfo;
  },
  setUserId: (state, user_id) => {
    state.user_id = user_id;
  },
  logout: (state) => {
    state.name = "";
    state.user_id = "";
    state.userinfo = "";
    state.login_status = false;
  },
  login: (state) => {
    state.login_status = true;
  },
  click_order: (state, status) => {
    state.click_order_status = status;
  },
};

//创建VueX对象
export default new Vuex.Store({
  state,
  mutations,
});
